<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>AjaxDemo1</title>
</head>
<body>

   <button id="btn" onclick="ajaxClick()" >发送请求</button>
</body>

<script type="text/javascript">


    //发送Ajax请求
    function ajaxClick()
    {
        var xmlhttp;
        //1.创建对象 区分IE和非IE浏览器
         xmlhttp = new XMLHttpRequest()

        //2.发送请求

        //2.1 设置请求方式
        xmlhttp.open("GET","/Ajax-01/ajaxServlet");

         //2.2 发送请求
        xmlhttp.send();
        //3.获取响应

        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.status == 200 && xmlhttp.readyState == 4)
            {
                alert(xmlhttp.responseText);
            }
        }


    }

</script>
</html>